package com.oocl.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.oocl.exception.MyException;
import com.oocl.pojo.Food;
import com.oocl.service.FoodService;
import com.oocl.service.impl.FoodServiceImpl;

/**
 * Servlet implementation class FoodListServlet
 */
public class FoodListServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 String icnum = (String) request.getSession().getAttribute("icnum");
		 FoodService fSer = new FoodServiceImpl();
		 try {
			List<Food> list = fSer.loadFoodsByIcnum(icnum);
			System.out.print(list.size());
			request.setAttribute("list", list);
			request.getRequestDispatcher("foodlist.jsp").forward(request, response);
		} catch (MyException e) {
			e.printStackTrace();
		}
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request,response);
	}

}
